/*jslint vars: true, forin: true, sloppy: true */
/*global probe, angular */
probe.controller("DictionaryPreview", function ($scope, $element, ocDialog) {
	var patterns = [], roll, DI = ocDialog.queryDI($element);
	$scope.randDict = [];
	$scope.fieldCtrl = {
		header: (function () {
			var header = [];
			angular.forEach(DI.share.field, function (define) {
				this.push({
					text: define.name,
					width: 120
				});
				patterns.push(new RegExp(define.pattern));
			}, header);

			return header;
		}()),
		$position: {row: 0, col: 0}
	};

	roll = function () {
		var i, row;
		$scope.randDict.length = 0;
		for (i = 0; i < 20; i += 1) {
			row = [];
			angular.forEach(patterns, function (reg) {
				row.push(reg.gen);
			});
			$scope.randDict.push(row);
		}
	};
	roll();

	$scope.roll = function () {
		$scope.r = !$scope.r;
		roll();
	};
});
